<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>3D地图获取经纬度</title>
    <link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css"/>
        <script type="text/javascript">
            window._AMapSecurityConfig = {
                securityJsCode: '599ea618c90118d7cf99a2b4422b9b6b',
            }
        </script>
    <script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key=4ade705af88de2da3ccce059f84d5e4b"></script>
	
	<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
	
</head>
<body>
<div id="container" class="map" style="width:100%; height:100%;resize:both;"></div>
<div class="input-card">
    <h4>左击获取经纬度：</h4>
    <div class="input-item">
      <input type="text" readonly="true" id="lnglat">
    </div>
</div>
<div id="myPageTop">	
    <table>
        <tr>
            <td>
                <label>请输入关键字：</label>
            </td>
        </tr>
        <tr>
            <td>
                <input id="tipinput"/>
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">
    //地图加载
    var map = new AMap.Map('container', {
    rotateEnable:true,
	resizeEnable: true,
    pitchEnable:true,
    zoom: 17,
    pitch: 50,

    rotation: -15,
    viewMode:'3D', //开启3D视图,默认为关闭
    zooms:[2,20],
    center:[104.10113,30.675639]
  });
    //输入提示
    var autoOptions = {
        input: "tipinput"
    };

    AMap.plugin(['AMap.PlaceSearch','AMap.AutoComplete'], function(){
        var auto = new AMap.AutoComplete(autoOptions);
        var placeSearch = new AMap.PlaceSearch({
            map: map
        });  //构造地点查询类
        auto.on("select", select);//注册监听，当选中某条记录时会触发
        function select(e) {
            placeSearch.setCity(e.poi.adcode);
            placeSearch.search(e.poi.name);  //关键字查询查询
        }
    });
	
	//为地图注册click事件获取鼠标点击出的经纬度坐标
	map.on('click', function(e) {
		document.getElementById("lnglat").value = e.lnglat.getLng() + ',' + e.lnglat.getLat()
	});
	
	AMap.plugin([
        'AMap.ControlBar',
    ], function(){

        // 添加 3D 罗盘控制
        map.addControl(new AMap.ControlBar());
	});
</script>
</body>
</html>